/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "credititempharmacy")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Credititempharmacy.findAll", query = "SELECT c FROM Credititempharmacy c"),
    @NamedQuery(name = "Credititempharmacy.findByAccountsPayableIdByPackageIdByItemId", query = "SELECT c FROM Credititempharmacy c WHERE c.credititempharmacyPK.accountsPayableId = :accountsPayableId AND c.credititempharmacyPK.packageId = :packageId AND c.credititempharmacyPK.itemId = :itemId"),
    @NamedQuery(name = "Credititempharmacy.deleteByAccountsPayableIdByPackageIdByItemId", query = "DELETE FROM Credititempharmacy c WHERE c.credititempharmacyPK.accountsPayableId = :accountsPayableId AND c.credititempharmacyPK.packageId = :packageId AND c.credititempharmacyPK.itemId = :itemId"),
    @NamedQuery(name = "Credititempharmacy.findByPackageIdByItemId", query = "SELECT c FROM Credititempharmacy c WHERE c.credititempharmacyPK.packageId = :packageId AND c.credititempharmacyPK.itemId = :itemId"),
    @NamedQuery(name = "Credititempharmacy.findByPackageId", query = "SELECT c FROM Credititempharmacy c WHERE c.credititempharmacyPK.packageId = :packageId"),
    @NamedQuery(name = "Credititempharmacy.findByItemId", query = "SELECT c FROM Credititempharmacy c WHERE c.credititempharmacyPK.itemId = :itemId"),
    @NamedQuery(name = "Credititempharmacy.findByAccountsPayableId", query = "SELECT c FROM Credititempharmacy c WHERE c.credititempharmacyPK.accountsPayableId = :accountsPayableId")})
public class Credititempharmacy implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CredititempharmacyPK credititempharmacyPK;
    @JoinColumn(name = "accountsPayableId", referencedColumnName = "accountsPayableId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Accountspayable accountspayable;
    @JoinColumns({
        @JoinColumn(name = "packageId", referencedColumnName = "packageId", insertable = false, updatable = false),
        @JoinColumn(name = "itemId", referencedColumnName = "itemId", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Item item;

    public Credititempharmacy() {
    }

    public Credititempharmacy(CredititempharmacyPK credititempharmacyPK) {
        this.credititempharmacyPK = credititempharmacyPK;
    }

    public Credititempharmacy(int packageId, int itemId, int accountsPayableId) {
        this.credititempharmacyPK = new CredititempharmacyPK(packageId, itemId, accountsPayableId);
    }

    public CredititempharmacyPK getCredititempharmacyPK() {
        return credititempharmacyPK;
    }

    public void setCredititempharmacyPK(CredititempharmacyPK credititempharmacyPK) {
        this.credititempharmacyPK = credititempharmacyPK;
    }

    public Accountspayable getAccountspayable() {
        return accountspayable;
    }

    public void setAccountspayable(Accountspayable accountspayable) {
        this.accountspayable = accountspayable;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (credititempharmacyPK != null ? credititempharmacyPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Credititempharmacy)) {
            return false;
        }
        Credititempharmacy other = (Credititempharmacy) object;
        if ((this.credititempharmacyPK == null && other.credititempharmacyPK != null) || (this.credititempharmacyPK != null && !this.credititempharmacyPK.equals(other.credititempharmacyPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Credititempharmacy[ credititempharmacyPK=" + credititempharmacyPK + " ]";
    }
    
}
